/**
 * DiggApiNet - Digg API .NET Wrapper
 * 
 * Author: Sean Hickey
 * Link: http://www.headzoo.com/digg_api_net
 * License: GPL v2 ( http://www.gnu.org/licenses/gpl.txt )
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace DiggApiNet
{
    public class DiggUser : DiggReturnBase
    {
        public string       Name
        {
            get
            {
                XmlNode node = (XmlNode)_dict["user"];
                return node.Attributes["name"].InnerText;
            }
        }
        public string       Icon
        {
            get
            {
                XmlNode node = (XmlNode)_dict["user"];
                return node.Attributes["icon"].InnerText;
            }
        }
        public DateTime     Registered
        {
            get
            {
                XmlNode node = (XmlNode)_dict["user"];
                if (node.Attributes["registered"] == null) {
                    return new DateTime();
                }
                return GetDateTimeFromTimeStamp(node.Attributes["registered"].InnerText);
            }
        }
        public int          ProfileViews
        {
            get
            {
                XmlNode node = (XmlNode)_dict["user"];
                if (node.Attributes["profileviews"] == null) {
                    return 0;
                }
                return int.Parse(node.Attributes["profileviews"].InnerText);
            }
        }

        public DiggUser(XmlDocument xml_doc) : this(xml_doc.SelectSingleNode("users").SelectSingleNode("user"))
        {
            
        }
        public DiggUser(XmlNode node) : base(node)
        {
            
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
